package com.ams.io;

import java.nio.ByteBuffer;

public final class BufferFactory {
    private static IBufferAllocator allocator = null;

    public static ByteBuffer allocate(int size) {
        if (allocator == null) {
            return ByteBuffer.allocateDirect(size);
        }
        return allocator.allocate(size);
    }

    public static void setAllocator(IBufferAllocator alloc) {
        allocator = alloc;
    }

}
